//2009/07/31 10:26:51
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <math.h>

using namespace std;

class BenfordsLaw
{
public:
    int questionableDigit(vector <int> trans, int threshold)
    {
        int count[10];
		memset(count, 0, sizeof(count));

        for (int i=0; i<trans.size(); i++)
        {
            string ss = convertIntegerToString(trans[i]);
            count[ss[0] - '0'] ++;
        }
        double th = threshold;
        for (int i=1; i<10; i++)
        {
            double p = trans.size() * log10(1.0  + 1.0/ double(i));
            if (count[i]*threshold < p || count[i] / th > p)
                return i;
        }
        return -1;
    }
private:
    string convertIntegerToString(int number)
    {
        stringstream s;			
        s << number;				
        return s.str();		
    }
};
